home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / compuserve-file-archive / 22 Graphics & Utilities / PSDUMP.SRC < prev    next >
Encoding:
Text File  |  2019-04-13  |  17.4 KB  |  1,093 lines

  1. .opt nosym
  2.  chkin=$ffc6 ;kernal routines
  3.  chkout=$ffc9
  4.  chrout=$ffd2
  5.  clall=$ffe7
  6.  close=$ffc3
  7.  clrchn=$ffcc
  8.  getin=$ffe4
  9.  ioinit=$ff84
  10.  open=$ffc0
  11.  plot=$fff0
  12.  readst=$ffb7
  13.  restor=$ff8a
  14.  setlfs=$ffba
  15.  setnam=$ffbd
  16.  stop=$ffe1
  17. ;
  18.  rcount=168 ;# of rows printed
  19.  ccount=169 ;# of columns
  20.  strlo=170 ;used by print-string routine
  21.  strhi=171
  22.  bitts=180 ;misc. variable
  23.  flsh=181 ;used by cursor flash
  24.  disk=820 ;store filename before translation
  25.  derr=840 ;disk error message
  26.  dsknam=49152
  27. ;
  28. ;use the monitor to:
  29. ;.l "0:psg screen",08
  30. ;.t c000 c7cf 086f
  31. ;
  32. ;files:                   device #:
  33. ;2  disk data channel     8
  34. ;4  printer               4
  35. ;15 disk command channel  8
  36. ;
  37.  *=2049 ;build basic statement 'sys2131'
  38.  .word 2100
  39.  .word $0001
  40.  .byte 158,'2131:',143,20,20,20,20,20,20,20,20,'64738:'
  41.  .byte 143,' for gemini 10-x printer',0
  42.  .word 2129
  43.  .word $0002
  44.  .byte 143,' type ',34,'run',34,' to begin...',0
  45.  .word 0
  46.  jmp top
  47. datop .byte 'i0',13,0
  48. blread .byte 'u1: 2 0 tr se',13,0
  49. nextr .byte 18
  50. nexse .byte 0
  51. opscr .byte 142,147,8,0
  52. opscr1  ;screen--fill with monitor
  53.  *=*+1000
  54. opscr2  ;color--fill with monitor
  55.  *=*+1000
  56. cursor .byte 5,163,5,183,5,184
  57.  .byte 18,162,18,185,18,175,18,164
  58.  .byte 18,32,18,163,18,183,18,184
  59.  .byte 5,162,5,185,5,175,5,164,5,32
  60. msg1 .byte 147,159
  61.  .byte 'print ',158,'shop ',30,'graphics '
  62.  .byte 5,'dump',13,13
  63.  .byte 'by andrew siguenza',13,13
  64.  .byte '   apt. 6',13,'   10739 roosevelt way ne',13
  65.  .byte '   seattle, wa  98125',13,13
  66.  .byte 'this program prints all the ''print',13
  67.  .byte 'shop'' graphics on a disk onto a gemini',13
  68.  .byte '10-x printer in rows of eight.',13,0
  69. msg2 .byte 13,13,39,'print shop'' is a trademark of',13
  70.  .byte 'broderund software co.',13,13,153
  71.  .byte 158,'hold down the stop key to abort',5,13
  72.  .byte 'insert graphics disk and press a key',0
  73. msg3 .byte 13,'?timeout',133
  74. errmsg .byte ' error',13,'(a)bort or (r)etry? '
  75.  .byte 0
  76. msg4 .byte 'retry',13,0
  77. msg5 .byte 158,'abort',5,13,0
  78. msg6 .byte 13,18,158,'?disk error:',5,13,0
  79. block .byte '#'
  80. const .byte '18 00'
  81. point .byte 'b-p: 2 255',13,0
  82. msg7 .byte 32,13,'ok',13,0
  83. msg8 .byte 196,'isk ',206,'ame: ',0
  84. msg9 .byte '?printer not on',160
  85. msg10 .byte 146,'     page '
  86. page .byte 48,0
  87. flag1 .byte 0 ;rotate count
  88. flag2 .byte 0 ;# of filename
  89. data ;storage addresses for graphic data
  90.  .word 23296
  91.  .word 24064
  92.  .word 24832
  93.  .word 25600
  94.  .word 26368
  95.  .word 27136
  96.  .word 27904
  97.  .word 28672
  98. msg11 .byte 13,18,' all done! ',9,0
  99. msg12 .byte 'reading ',0
  100. msg13 .byte 13,158,'........printing........',5,13,13,0
  101. ;
  102. top lda #11 ;dark grey border
  103.  sta 53280
  104.  sta 53265 ;blank screen
  105.  lda #0
  106.  sta 53281 ;black screen
  107.  jsr clall
  108.  jsr ioinit
  109.  jsr restor
  110.  ldx #0 ;clear screen etc.
  111. t1 lda opscr,x
  112.  beq t2
  113.  jsr chrout
  114.  inx
  115.  bne t1
  116. t2 lda #0 ;move data to screen mem.
  117.  sta 251
  118.  lda #4
  119.  sta 252
  120.  lda #<opscr1 ;data pointer
  121.  sta 253
  122.  lda #>opscr1
  123.  sta 254
  124. t3 ldy #0
  125.  lda (253),y
  126.  sta (251),y
  127.  inc 253 ;add 1 to data pointer
  128.  bne *+4
  129.  inc 254
  130.  inc 251 ;add 1 to screen pointer
  131.  bne *+4
  132.  inc 252
  133.  lda 252 ;end of screen?
  134.  cmp #7
  135.  bne t3 ;no
  136.  lda 251
  137.  cmp #231
  138.  bne t3 ;no
  139.  lda #0 ;yes--now do color
  140.  sta 251
  141.  lda #216
  142.  sta 252
  143.  lda #<opscr2 ;table pointer
  144.  sta 253
  145.  lda #>opscr2
  146.  sta 254
  147. t4 ldy #0
  148.  lda (253),y
  149.  sta (251),y
  150.  inc 253 ;add 1 to data pointer
  151.  bne *+4
  152.  inc 254
  153.  inc 251 ;add 1 to screen pointer
  154.  bne *+4
  155.  inc 252
  156.  lda 252 ;end of color mem.?
  157.  cmp #219
  158.  bne t4 ;no
  159.  lda 251
  160.  cmp #231
  161.  bne t4 ;no
  162.  lda #27 ;yes
  163.  sta 53265 ;un-blank screen
  164.  ldx #23 ;move cursor position to 32,23
  165.  ldy #32
  166.  clc
  167.  jsr plot
  168.  jsr flash ;wait for key
  169.  lda #<msg1 ;credits
  170.  ldy #>msg1
  171.  jsr strout
  172.  lda #<msg2
  173.  ldy #>msg2
  174.  jsr strout
  175.  jsr flash ;wait for key
  176.  cmp #3 ;stop key pressed?
  177.  bne *+5 ;no
  178.  jmp abort ;yes
  179.  lda #32 ;erase cursor
  180.  jsr chrout
  181.  lda #13
  182.  jsr chrout
  183.  lda #<msg7 ;print 'ok'
  184.  ldy #>msg7
  185.  jsr strout
  186.  lda #0 ;open command channel
  187.  jsr setnam
  188.  lda #15 ;file no.
  189.  ldx #8 ;device
  190.  ldy #15 ;channel 15
  191.  jsr setlfs
  192.  jsr open
  193. t5 ldx #15 ;set file #15 for output
  194.  jsr chkout
  195.  lda #<datop ;initialize drive
  196.  ldy #>datop
  197.  jsr strout
  198.  jsr readst ;check disk status
  199.  pha
  200.  jsr clrchn
  201.  pla
  202.  and #131 ;test for error
  203.  beq t7 ;no error
  204.  and #3 ;no device?
  205.  beq t6 ;yes
  206.  lda #<msg3 ;print timeout error message
  207.  ldy #>msg3
  208.  jsr error
  209.  bcc t5 ;retry
  210.  jmp abort
  211. t6 lda 41776 ;print device not present message
  212.  ldy 41777
  213.  jsr error
  214.  bcc t5 ;retry
  215.  jmp abort
  216. t7 jsr erchan ;read error channel
  217.  bcc t8 ;no error
  218.  jsr clrchn ;reset screen output
  219.  lda #<msg6 ;print disk error message
  220.  ldy #>msg6
  221.  jsr strout
  222.  lda #<derr
  223.  ldy #>derr
  224.  jsr error
  225.  bcc t5
  226.  jmp abort
  227. t8 lda #2 ;open direct-access buffer
  228.  ldx #8
  229.  ldy #2
  230.  jsr setlfs
  231.  lda #1
  232.  ldx #<block
  233.  ldy #>block
  234.  jsr setnam
  235.  jsr open
  236.  jsr erchan
  237.  bcc t9
  238.  lda #2 ;close buffer channel
  239.  jsr close
  240.  jsr clrchn ;reset screen output
  241.  lda #<msg6 ;print disk error message
  242.  ldy #>msg6
  243.  jsr strout
  244.  lda #<derr
  245.  ldy #>derr
  246.  jsr error
  247.  bcc t8
  248.  jmp abort
  249. t9 ldx #4 ;read disk name:
  250.  lda const,x ;set 18,0
  251.  sta blread+8,x
  252.  dex
  253.  bpl t9+2
  254.  ldx #15
  255.  jsr chkout
  256.  lda #<blread
  257.  ldy #>blread
  258.  jsr strout
  259.  jsr clrchn
  260.  jsr erchan
  261.  bcc t10
  262.  lda #<msg6 ;'disk error'
  263.  ldy #>msg6
  264.  jsr strout
  265.  lda #<derr
  266.  ldy #>derr
  267.  jsr error
  268.  bcc t9
  269.  jmp abort
  270. t10 lda #'1 ;buffer point to 144
  271.  sta point+7
  272.  lda #'4
  273.  sta point+8
  274.  sta point+9
  275.  ldx #15
  276.  jsr chkout
  277.  lda #<point
  278.  ldy #>point
  279.  jsr strout
  280.  jsr clrchn
  281.  lda #0
  282.  jsr dname
  283. t11 jsr opengr ;open printer file
  284.  jsr clrchn
  285.  ldx #4 ;test for printer present
  286.  jsr chkout
  287.  lda #0
  288.  jsr chrout
  289.  jsr readst ;check printer status
  290.  and #255 ;error?
  291.  beq t12 ;no
  292.  lda #4 ;yes--close printer file
  293.  jsr close
  294.  jsr clrchn
  295.  lda #<msg9 ;'?printer not on'
  296.  ldy #>msg8
  297.  jsr error
  298.  bcc t11 ;retry
  299.  jmp abort
  300. t12 lda #'0
  301.  sta page ;set page number
  302.  jsr ptop ;output to printer
  303.  lda #0
  304.  sta rcount
  305.  inc blread+12 ;set up to read 18,1
  306.  lda #0 ;first filename
  307.  sta ccount
  308.  lda #18
  309.  sta nextr
  310.  sta oldtr
  311.  lda #1
  312.  sta oldse
  313.  sta nexse
  314.  lda #8
  315.  sta flag2
  316. main jsr stop
  317.  bne *+5
  318.  jmp abort
  319.  jsr clrchn
  320.  lda flag2
  321.  cmp #8 ;last filename in block?
  322.  bne ma0 ;no
  323.  lda nextr ;yes
  324.  cmp #0 ;last directory block?
  325.  bne *+5 ;no
  326.  jmp print ;yes-we're done, print last row
  327.  jsr readtr
  328.  lda #0
  329.  sta flag2
  330. ma0 asl a ;get ascii characters from table
  331.  clc ;  to set buffer pointer to read
  332.  adc flag2 ;  next file name
  333.  tax
  334.  inc flag2
  335.  lda numbr2,x
  336.  sta point+7
  337.  lda numbr2+1,x
  338.  sta point+8
  339.  lda numbr2+2,x
  340.  sta point+9
  341.  ldx #15
  342.  jsr chkout
  343.  lda #<point
  344.  ldy #>point
  345.  jsr strout
  346.  jsr clrchn
  347.  ldx #2
  348.  jsr chkin
  349.  jsr getin ;check file type
  350.  and #131
  351.  cmp #130 ;program?
  352.  bne main ;no
  353.  jsr getin ;skip 2-byte block link
  354.  jsr getin
  355.  ldx ccount
  356.  inx
  357.  txa
  358.  jsr dname
  359.  ldx #2
  360.  jsr chkin
  361.  ldx #8 ;skip over 9 bytes
  362.  stx bitts
  363. ma1 jsr getin
  364.  dec bitts
  365.  bpl ma1
  366.  jsr getin ;get no. blocks in file
  367.  sta 251
  368.  jsr getin
  369.  sta 252
  370.  lda #3 ;test for 3-block length
  371.  cmp 251
  372.  bne *+8
  373.  lda #0
  374.  cmp 252
  375.  beq *+5
  376.  jmp main
  377.  lda #2 ;close direct access, open regular
  378.  jsr close ;  program file access
  379.  jsr clrchn
  380.  lda #<msg12 ;'reading' filename
  381.  ldy #>msg12
  382.  jsr strout
  383.  ldx ccount ;find filename
  384.  inx
  385.  txa
  386.  jsr mult48
  387.  lda #192
  388.  clc
  389.  adc 254
  390.  sta 254
  391.  lda 253
  392.  ldy 254
  393.  jsr strout ;print filename
  394.  lda #13 ;print cr
  395.  jsr chrout
  396.  ldx #3
  397. ma2 lda data2,x ;append ',p,r'
  398.  sta 836,x
  399.  dex
  400.  bpl ma2
  401.  lda #20
  402.  ldx #<disk
  403.  ldy #>disk
  404.  jsr setnam
  405.  lda #2
  406.  ldx #8
  407.  ldy #2
  408.  jsr setlfs
  409.  jsr open
  410.  jsr erchan ;error?
  411.  bcc ma3
  412.  lda #2
  413.  jsr close
  414.  jsr clrchn
  415.  lda #<msg6 ;'disk error'
  416.  ldy #>msg6
  417.  jsr strout
  418.  lda #<derr
  419.  ldy #>derr
  420.  jsr error
  421.  bcc ma2+9
  422.  jmp abort
  423. ma3 ldx #2
  424.  jsr chkin
  425.  jsr getin ;skip over load address
  426.  jsr getin
  427.  jsr readst ;error?
  428.  and #255
  429.  beq *+5
  430.  jmp main ;end of file, skip it
  431.  lda #88
  432.  sta 252 ;set pointer to ps graphic data
  433.  lda #0
  434.  sta 251
  435.  sta 253 ;set byte counter
  436.  sta 254
  437. ma4 jsr getin
  438.  ldy #0
  439.  sta (251),y
  440.  jsr readst ;check for end-of-file
  441.  and #255
  442.  bne ma5 ;end
  443.  lda #2 ;check for 572 bytes received
  444.  cmp 254 ;  (print shop grahpic file
  445.  bne *+10 ;  is 572 bytes long)
  446.  lda #60
  447.  cmp 253
  448.  bne *+4
  449.  beq ma5
  450.  inc 251 ;increment pointers
  451.  bne *+4
  452.  inc 252
  453.  inc 253
  454.  bne ma4
  455.  inc 254
  456.  bne ma4
  457. ma5 inc 251 ;when routine gets to here,
  458.  bne *+4 ;  pointers point to last
  459.  inc 252 ;  byte loaded
  460.  inc 253
  461.  bne *+4
  462.  inc 254
  463.  lda #2
  464.  jsr close
  465.  ldy #0 ;fill rest of graphic area with
  466. ma6 tya ;  zeros
  467.  sta (251),y
  468.  inc 251
  469.  bne *+4
  470.  inc 252
  471.  inc 253
  472.  bne *+4
  473.  inc 254
  474.  lda 253 ;done? (768 bytes per graphic
  475.  cmp #0 ;  area)
  476.  bne ma6 ;no
  477.  lda 254
  478.  cmp #3
  479.  bne ma6 ;no
  480.  lda #$58 ;rotate graphic data for printer
  481.  sta roa+2
  482.  lda ccount ;get high byte for destination
  483.  asl a ;  address
  484.  tax
  485.  inx
  486.  lda data,x
  487.  sta rob+2
  488.  clc
  489.  adc #2 ;this number will serve as the end-
  490.  sta flag1 ;  of-rotate flag
  491.  lda #11
  492.  sta roc
  493.  lda #0
  494.  sta roa+1
  495.  sta rob+1
  496. ro1 ldy #$07
  497. ro2 ldx #$4d
  498.  lda #$00
  499. ro3 clc
  500. roa lsr $5800,x ;this address gets modified
  501.  ror a ;when the program runs
  502.  dex
  503.  dex
  504.  dex
  505.  dex
  506.  dex
  507.  dex
  508.  dex
  509.  dex
  510.  dex
  511.  dex
  512.  dex
  513.  bpl ro3
  514. rob sta $5a00,y ;this address gets modified
  515.  dey ;  when the program runs
  516.  bpl ro2
  517.  inc roa+1
  518.  bne ro4
  519.  inc roa+2
  520. ro4 lda roa+1
  521.  cmp roc
  522.  bne ro6
  523.  clc
  524.  adc #$4d
  525.  sta roa+1
  526.  bcc ro5
  527.  inc roa+2
  528.  clc
  529. ro5 adc #11 ;next row
  530.  sta roc
  531.  cmp #115
  532.  beq ro7
  533. ro6 lda #8
  534.  clc
  535.  adc rob+1
  536.  sta rob+1
  537.  bcc ro1
  538.  inc rob+2
  539.  jmp ro1
  540. ro7 lda rob+2
  541.  cmp flag1
  542.  bne ro1
  543. ;
  544. ma7 lda #2 ;re-open direct-access channel
  545.  ldx #8
  546.  ldy #2
  547.  jsr setlfs
  548.  lda #1
  549.  ldx #<block
  550.  ldy #>block
  551.  jsr setnam
  552.  jsr open
  553.  jsr erchan ;disk error?
  554.  bcc ma8 ;no
  555.  lda #<msg6 ;yes
  556.  ldy #>msg6
  557.  jsr strout
  558.  lda #<derr
  559.  ldy #>derr
  560.  jsr error
  561.  bcc ma7
  562.  jmp abort
  563. ma8 lda oldtr ;re-read directory block
  564.  sta nextr
  565.  lda oldse
  566.  sta nexse
  567.  jsr readtr
  568.  inc ccount ;increment column counter
  569.  lda #8
  570.  cmp ccount ;time to print a row?
  571.  beq print ;yes
  572.  jmp main ;no
  573. print jsr clrchn
  574.  lda #<msg13 ;'printing'
  575.  ldy #>msg13
  576.  jsr strout
  577.  ldx #4
  578.  jsr chkout
  579.  lda #0 ;7 hi-res rows to print
  580.  sta 251
  581. pr0 lda ccount ;no. of graphics to print
  582.  sta 252 ;  (normally seven except for
  583. pr1 dec 252 ;  last row)
  584.  bmi prnext ;this byte row is done
  585.  ldx ccount ;pointer to entry in table
  586.  dex ;  = (6-column number)*2
  587.  txa
  588.  sec
  589.  sbc 252
  590.  asl a
  591.  tax
  592.  lda data,x ;get base pointer
  593.  sta 253
  594.  lda data+1,x
  595.  sta 254
  596.  lda 251 ;add row increment
  597.  asl a
  598.  tax
  599.  lda numbr3,x
  600.  clc
  601.  adc 253
  602.  sta 253
  603.  lda numbr3+1,x
  604.  adc 254
  605.  sta 254
  606.  jsr opengr
  607.  ldx #4
  608.  jsr chkout
  609.  ldx #0
  610.  stx bitts
  611. pra lda dbits,x
  612.  jsr chrout
  613.  ldx bitts
  614.  inx
  615.  stx bitts
  616.  cpx #4
  617.  bne pra
  618.  ldy #0
  619. pr3 lda (253),y
  620.  jsr chrout
  621.  iny
  622.  cpy #88
  623.  bne pr3
  624.  lda #<space
  625.  ldy #>space
  626.  jsr strout
  627.  jmp pr1 ;do next column
  628. prnext lda #<crlf
  629.  ldy #>crlf
  630.  jsr strout
  631.  jsr stop ;test stop key
  632.  bne *+5
  633.  jmp abort
  634.  inc 251 ;increment byte row counter
  635.  lda #7
  636.  cmp 251 ;last byte row done?
  637.  bne pr0 ;no
  638.  lda #<crlf ;yes--print one blank line
  639.  ldy #>crlf
  640.  jsr strout
  641.  lda #<comprs ;set 15 pitch
  642.  ldy #>comprs
  643.  jsr strout
  644.  jsr opentx
  645.  ldx #4
  646.  jsr chkout
  647.  ldx ccount ;now print graphic names
  648.  stx bitts
  649. pr4 dec bitts
  650.  bmi prdone
  651.  ldx ccount ;filename is at (6-ccount)*48 + 49200
  652.  dex
  653.  txa
  654.  sec
  655.  sbc bitts
  656.  jsr mult48
  657.  lda #48
  658.  clc
  659.  adc 253
  660.  sta 253
  661.  lda 254
  662.  adc #192
  663.  sta 254
  664.  lda 253
  665.  ldy 254
  666.  jsr strout ;print name
  667.  lda #146 ;rvs-off (printer code)
  668.  jsr chrout
  669.  lda #32 ;space between names
  670.  jsr chrout
  671.  jmp pr4
  672. prdone jsr opengr
  673.  ldx #4
  674.  jsr chkout
  675.  lda #<elite ;reset 12 pitch
  676.  ldy #>elite
  677.  jsr strout
  678.  ldx #3 ;cr + 3 blank lines
  679.  stx bitts
  680. pr6 lda #<crlf
  681.  ldy #>crlf
  682.  jsr strout
  683.  dec bitts
  684.  bpl pr6
  685.  inc rcount ;end of page?
  686.  lda #7
  687.  cmp rcount
  688.  bne pr7 ;no
  689.  ldx #5 ;yes--print six blank lines at
  690.  stx bitts ;  the bottom
  691. pr6a lda #<crlf
  692.  ldy #>crlf
  693.  jsr strout
  694.  dec bitts
  695.  bpl pr6a
  696.  jsr ptop ;  and print the header
  697. pr7 jsr clrchn
  698.  lda #0
  699.  sta ccount
  700.  lda nextr ;was this the last row?
  701.  cmp #0
  702.  beq *+5
  703.  jmp main ;no
  704.  lda flag2
  705.  cmp #8
  706.  bne *-8 ;no
  707. ;
  708. abort lda #4 ;close printer file
  709.  jsr close
  710.  lda #2 ;close disk data channel
  711.  jsr close
  712.  lda #15 ;close disk command channel
  713.  jsr close
  714.  jsr clall ;reset i/o
  715.  lda #<msg11 ;print 'all done'
  716.  ldy #>msg11
  717.  jsr strout
  718.  rts ;return to basic
  719. ;
  720. ;more data
  721. prinit .byte 27,65,8,27,85,1,0
  722. crlf .byte 13,10,0
  723. dbits .byte 27,76,88,0
  724. elite .byte 27,66,2,0
  725. comprs .byte 27,66,3,0
  726. space .byte '   ',0
  727. number .byte '00010203040506070809101112131415'
  728.  .byte '16171819202122232425262728293031'
  729. numbr2 .byte '002034066098130162194226'
  730. roc .byte 169
  731. numbr3 .byte 0,0,88,0,176,0,8,1
  732.  .byte 96,1,184,1,16,2
  733. data2 .byte ',p,r'
  734. oldtr .byte 18
  735. oldse .byte 1
  736. pica .byte 27,66,1,0
  737. ;
  738. ;subroutines start here
  739. ;
  740. flash lda #0 ;flash cursor, wait for key
  741.  sta flsh ;cursor data pointer
  742. fl1 jsr getin ;check keyboard
  743.  cmp #0 ;key pressed?
  744.  beq *+3 ;no
  745.  rts ;yes
  746.  lda flsh ;get pointer (0-15)
  747.  asl a ;multiply by 2
  748.  tax
  749.  lda cursor,x ;get cursor character
  750.  jsr chrout ;print it
  751.  inx
  752.  lda cursor,x
  753.  jsr chrout
  754.  lda #146 ;rvs-off
  755.  jsr chrout
  756.  lda #157 ;cursor left
  757.  jsr chrout
  758.  ldx flsh ;add 1 to pointer
  759.  inx
  760.  txa
  761.  and #15
  762.  sta flsh
  763.  ldy #35
  764. fl2 ldx #255 ;short delay
  765. fl3 dex
  766.  bne fl3
  767.  dey
  768.  bne fl2
  769.  beq fl1 ;delay done
  770. ;
  771. error sta 251
  772.  sty 252
  773.  jsr clrchn ;reset screen/keyboard
  774. er1 ldy #0
  775.  lda (251),y ;read table
  776.  pha
  777.  and #127
  778.  jsr chrout
  779.  pla
  780.  and #128 ;end of table?
  781.  bne er2 ;yes
  782.  inc 251 ;add 1 to pointer
  783.  bne er1
  784.  inc 252
  785.  bne er1 ;always goes
  786. er2 lda #<errmsg ;print ' error'
  787.  ldy #>errmsg
  788.  jsr strout
  789.  jsr flash
  790.  cmp #82 ;'r'?
  791.  bne er3 ;no
  792.  lda #<msg4 ;yes--retry
  793.  ldy #>msg4
  794.  jsr strout
  795.  clc
  796.  rts
  797. er3 lda #<msg5 ;no--abort
  798.  ldy #>msg5
  799.  jsr strout
  800.  sec
  801.  rts
  802. ;
  803. erchan ldx #15 ;read disk error channel
  804.  jsr chkin
  805.  ldy #4 ;error message has 4 cr's
  806.  sty 251
  807.  ldx #0
  808.  stx 252
  809. erc1 jsr getin
  810.  cmp #0 ;note:  drive should not return
  811.  beq erc2 ;  a zero byte
  812.  cmp #13 ;cr?
  813.  bne *+4 ;no
  814.  lda #44 ;yes--change to ','
  815.  ldx 252
  816.  sta derr,x
  817.  inc 252
  818.  cmp #44
  819.  bne erc1
  820.  dec 251
  821.  bne erc1
  822.  ldx 252
  823.  dex ;change last comma to shift-space
  824.  lda #160 ; for error subroutine
  825.  sta derr,x
  826.  jsr clrchn
  827.  lda #48 ;ascii zero
  828.  cmp derr ;check for error--set carry if error
  829.  bne erc2
  830.  cmp derr+1
  831.  bne erc2
  832.  clc
  833.  rts
  834. erc2 sec
  835.  rts
  836. ;
  837. strout sta strlo ;low byte
  838.  sty strhi ;high byte
  839. st1 ldy #0
  840.  lda (strlo),y
  841.  cmp #0
  842.  beq st2
  843.  jsr chrout
  844.  inc strlo
  845.  bne st1
  846.  inc strhi
  847.  bne st1
  848. st2 rts
  849. ;
  850. dname sta 254
  851.  ldx #0 ;get 16-character name
  852.  stx 251
  853.  ldx #2 ;buffer channel
  854.  jsr chkin
  855. dn2 jsr getin
  856.  ldx 251
  857.  sta disk,x
  858.  inx
  859.  stx 251
  860.  cpx #16
  861.  bne dn2
  862.  jsr clrchn
  863.  lda 254
  864.  jsr mult48 ;pointer=no. x 48 + 49152
  865.  lda #192
  866.  clc
  867.  adc 254
  868.  sta 254
  869.  ldy #0 ;translate 16-character file name
  870.  ldx #0 ;  and store in high memory
  871. dn3 lda disk,x ;read next byte
  872.  cmp #27 ;translation table:
  873.  bcs dn4 ; 0 - 26:  rvs+(@-z)
  874.  jsr dnsub ;     27:  rvs colon
  875.  jmp dnx ;     28:  rvs brit. pound
  876. dn4 cmp #27 ;     29:  rvs semi-colon
  877.  bne dn5 ;     30:  rvs up-arrow
  878.  lda #58 ;     31:  rvs equal-sign
  879.  jsr dnsub ;32 -127:  as is
  880.  jmp dnx ;128-159:  rvs 96-127
  881. dn5 cmp #28 ;    160:  32 (space)
  882.  bne dn6 ;161-191:  as is
  883.  lda #92 ;192-223:  same as 96-127
  884.  jsr dnsub ;224-254:  same as 160-190
  885.  jmp dnx ;    255:  same as 126
  886. dn6 cmp #29
  887.  bne dn7
  888.  lda #59
  889.  bne dn5+6
  890. dn7 cmp #30
  891.  bne dn8
  892.  lda #94
  893.  bne dn5+6
  894. dn8 cmp #31
  895.  bne dn9
  896.  lda #61
  897.  bne dn5+6
  898. dn9 cmp #128
  899.  bcs dn10
  900.  bcc dnw
  901. dn10 cmp #160
  902.  bcs dn11
  903.  sec
  904.  sbc #32
  905.  jsr dnsub
  906.  jmp dnx
  907. dn11 cmp #160
  908.  bne dn12
  909.  lda #32
  910.  bne dnw
  911. dn12 cmp #191
  912.  bcc dnw
  913.  cmp #224
  914.  bcs dn13
  915.  sec
  916.  sbc #96
  917.  bne dnw
  918. dn13 cmp #255
  919.  bcs dn14
  920.  sec
  921.  sbc #64
  922.  bne dn11
  923. dn14 lda #126
  924. dnw sta (253),y
  925.  iny
  926. dnx inx
  927.  cpx #16 ;done?
  928.  bne dn3 ;no
  929.  lda #0
  930. dny cpy #48
  931.  beq dnz
  932.  sta (253),y
  933.  iny
  934.  bne dny
  935. dnz rts
  936. ;
  937. dnsub pha ;part of dname routine
  938.  lda #18 ;rvs-on (printer code)
  939.  sta (253),y
  940.  pla ;character to be printed
  941.  iny
  942.  sta (253),y
  943.  iny
  944.  lda #146 ;rvs-off (printer code)
  945.  sta (253),y
  946.  iny
  947.  rts
  948. ;
  949. ;
  950. opentx lda #4 ;close old file
  951.  jsr close
  952.  lda #0
  953.  jsr setnam
  954.  lda #4 ;open printer file for text
  955.  ldx #4
  956.  ldy #8 ;no linefeed added by interface
  957.  jsr setlfs
  958.  jsr open
  959.  ;jsr clrchn
  960.  rts
  961. ;
  962. opengr lda #4 ;close old file
  963.  jsr close
  964.  lda #0
  965.  jsr setnam
  966.  lda #4 ;open printer file for graphics
  967.  ldx #4 ;set interface for pass-through
  968.  ldy #5 ;and no linefeed
  969.  jsr setlfs
  970.  jsr open
  971.  ;jsr clrchn
  972.  rts
  973. ;
  974. ptop inc page ;add 1 to page counter
  975.  jsr opengr ;initialize printer
  976.  ldx #4
  977.  jsr chkout
  978.  lda #<prinit ;set 17/144 linefeed, unidirectional print
  979.  ldy #>prinit
  980.  jsr strout
  981.  ldx #5
  982.  stx 251 ;set counter to print 5 blank
  983. pt1 lda #<crlf ;  lines
  984.  ldy #>crlf
  985.  jsr strout
  986.  dec 251
  987.  bne pt1
  988.  ldy #>pica ;set printer for 10 cpi
  989.  lda #<pica
  990.  jsr strout
  991.  jsr opentx
  992.  ldx #4
  993.  jsr chkout
  994.  lda #<msg8 ;'disk name:'
  995.  ldy #>msg8
  996.  jsr strout
  997.  lda #<dsknam ;print disk name
  998.  ldy #>dsknam
  999.  jsr strout
  1000.  lda #<msg10 ;print page number
  1001.  ldy #>msg10
  1002.  jsr strout
  1003.  ldx #4 ;carriage return + 3 blank lines
  1004.  stx 251
  1005. pt2 lda #<crlf
  1006.  ldy #>crlf
  1007.  jsr strout
  1008.  dec 251
  1009.  bne pt2
  1010.  jsr clrchn
  1011.  lda #0 ;reset row counter
  1012.  sta rcount
  1013.  jsr opengr
  1014.  ldx #4
  1015.  jsr chkout
  1016.  lda #<elite
  1017.  ldy #>elite
  1018.  jmp strout ;jump and return
  1019. ;
  1020. mult48 pha ;this routine multiplies a
  1021.  lda #0 ;  one-byte number in the
  1022.  sta 252 ;  accumulator by 48 and stores
  1023.  pla ;  it in 253,254 (low byte, high
  1024.  sta 251 ;  byte)
  1025.  ldx #4 ;double four times = 16
  1026. mu1 asl 251
  1027.  rol 252
  1028.  dex
  1029.  bne mu1
  1030.  lda 251 ;now multiply by 3 by repeated
  1031.  sta 253 ;  addition
  1032.  lda 252
  1033.  sta 254
  1034.  ldx #2
  1035. mu2 lda 253
  1036.  clc
  1037.  adc 251
  1038.  sta 253
  1039.  lda 254
  1040.  adc 252
  1041.  sta 254
  1042.  dex
  1043.  bne mu2
  1044.  rts ;result = 3x16 = 48
  1045. ;
  1046. readtr lda nextr
  1047.  sta oldtr
  1048.  lda nexse
  1049.  sta oldse
  1050.  lda nextr ;read next track & sector and
  1051.  and #31 ;  next-track pointer
  1052.  asl a
  1053.  tax
  1054.  lda number,x ;convert binary to 2-digit ascii
  1055.  sta blread+8 ;  by reading look-up table
  1056.  lda number+1,x
  1057.  sta blread+9
  1058.  lda nexse
  1059.  and #31
  1060.  asl a
  1061.  tax
  1062.  lda number,x
  1063.  sta blread+11
  1064.  lda number+1,x
  1065.  sta blread+12
  1066. re1 ldx #15
  1067.  jsr chkout
  1068.  lda #<blread
  1069.  ldy #>blread
  1070.  jsr strout
  1071.  jsr clrchn
  1072.  jsr erchan
  1073.  bcc re2
  1074.  lda #<msg6 ;'disk error'
  1075.  ldy #>msg6
  1076.  jsr strout
  1077.  lda #<derr
  1078.  ldy #>derr
  1079.  jsr error
  1080.  bcc re1
  1081.  pla ;clear subroutine return address
  1082.  pla
  1083.  jmp abort
  1084. re2 ldx #2
  1085.  jsr chkin
  1086.  jsr getin ;get byte #0 (next track)
  1087.  sta nextr
  1088.  jsr getin
  1089.  sta nexse
  1090.  rts
  1091. ;
  1092.  .end
  1093.